<?php require_once('../Connections/hitekforyou.php'); ?>
<?php
//MX Widgets3 include
require_once('../includes/wdg/WDG.php');

// Load the common classes
require_once('../includes/common/KT_common.php');

// Load the required classes
require_once('../includes/tfi/TFI.php');
require_once('../includes/tso/TSO.php');
require_once('../includes/nav/NAV.php');

// Make unified connection variable
$conn_hitekforyou = new KT_connection($hitekforyou, $database_hitekforyou);

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

// Filter
$tfi_listphieubaohanh3 = new TFI_TableFilter($conn_hitekforyou, "tfi_listphieubaohanh3");
$tfi_listphieubaohanh3->addColumn("phieubaohanh.idPBH", "NUMERIC_TYPE", "idPBH", "=");
$tfi_listphieubaohanh3->addColumn("hangsx.idHang", "NUMERIC_TYPE", "idHang", "=");
$tfi_listphieubaohanh3->addColumn("phieubaohanh.TGTraSP", "DATE_TYPE", "TGTraSP", "=");
$tfi_listphieubaohanh3->addColumn("phieubaohanh.TinhTrang", "CHECKBOX_1_0_TYPE", "TinhTrang", "%");
$tfi_listphieubaohanh3->Execute();

// Sorter
$tso_listphieubaohanh3 = new TSO_TableSorter("rsphieubaohanh1", "tso_listphieubaohanh3");
$tso_listphieubaohanh3->addColumn("phieubaohanh.idPBH");
$tso_listphieubaohanh3->addColumn("hangsx.TenHang");
$tso_listphieubaohanh3->addColumn("phieubaohanh.TGTraSP");
$tso_listphieubaohanh3->addColumn("phieubaohanh.TinhTrang");
$tso_listphieubaohanh3->setDefault("phieubaohanh.TGTraSP");
$tso_listphieubaohanh3->Execute();

// Navigation
$nav_listphieubaohanh3 = new NAV_Regular("nav_listphieubaohanh3", "rsphieubaohanh1", "../", $_SERVER['PHP_SELF'], 10);

mysql_select_db($database_hitekforyou, $hitekforyou);
$query_Recordset3 = "SELECT TenHang, idHang FROM hangsx ORDER BY TenHang";
$Recordset3 = mysql_query($query_Recordset3, $hitekforyou) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 = mysql_num_rows($Recordset3);

mysql_select_db($database_hitekforyou, $hitekforyou);
$query_Recordset4 = "SELECT TenHang, idHang FROM hangsx ORDER BY TenHang";
$Recordset4 = mysql_query($query_Recordset4, $hitekforyou) or die(mysql_error());
$row_Recordset4 = mysql_fetch_assoc($Recordset4);
$totalRows_Recordset4 = mysql_num_rows($Recordset4);

//NeXTenesio3 Special List Recordset
$maxRows_rsphieubaohanh1 = $_SESSION['max_rows_nav_listphieubaohanh3'];
$pageNum_rsphieubaohanh1 = 0;
if (isset($_GET['pageNum_rsphieubaohanh1'])) {
  $pageNum_rsphieubaohanh1 = $_GET['pageNum_rsphieubaohanh1'];
}
$startRow_rsphieubaohanh1 = $pageNum_rsphieubaohanh1 * $maxRows_rsphieubaohanh1;

// Defining List Recordset variable
$NXTFilter_rsphieubaohanh1 = "1=1";
if (isset($_SESSION['filter_tfi_listphieubaohanh3'])) {
  $NXTFilter_rsphieubaohanh1 = $_SESSION['filter_tfi_listphieubaohanh3'];
}
// Defining List Recordset variable
$NXTSort_rsphieubaohanh1 = "phieubaohanh.TGTraSP";
if (isset($_SESSION['sorter_tso_listphieubaohanh3'])) {
  $NXTSort_rsphieubaohanh1 = $_SESSION['sorter_tso_listphieubaohanh3'];
}
mysql_select_db($database_hitekforyou, $hitekforyou);

$query_rsphieubaohanh1 = "SELECT phieubaohanh.idPBH, hangsx.TenHang AS idHang, phieubaohanh.TGTraSP, phieubaohanh.TinhTrang FROM phieubaohanh LEFT JOIN hangsx ON phieubaohanh.idHang = hangsx.idHang WHERE {$NXTFilter_rsphieubaohanh1} ORDER BY {$NXTSort_rsphieubaohanh1}";
$query_limit_rsphieubaohanh1 = sprintf("%s LIMIT %d, %d", $query_rsphieubaohanh1, $startRow_rsphieubaohanh1, $maxRows_rsphieubaohanh1);
$rsphieubaohanh1 = mysql_query($query_limit_rsphieubaohanh1, $hitekforyou) or die(mysql_error());
$row_rsphieubaohanh1 = mysql_fetch_assoc($rsphieubaohanh1);

if (isset($_GET['totalRows_rsphieubaohanh1'])) {
  $totalRows_rsphieubaohanh1 = $_GET['totalRows_rsphieubaohanh1'];
} else {
  $all_rsphieubaohanh1 = mysql_query($query_rsphieubaohanh1);
  $totalRows_rsphieubaohanh1 = mysql_num_rows($all_rsphieubaohanh1);
}
$totalPages_rsphieubaohanh1 = ceil($totalRows_rsphieubaohanh1/$maxRows_rsphieubaohanh1)-1;
//End NeXTenesio3 Special List Recordset

$nav_listphieubaohanh3->checkBoundries();



error_reporting(0);
require_once('checklogin.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wdg="http://ns.adobe.com/addt">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="quantri.css" rel="stylesheet" type="text/css" />
<script src="../AC_RunActiveContent.js" type="text/javascript"></script>

<title>Trang chủ Quản trị</title>
<link href="../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="../includes/common/js/base.js" type="text/javascript"></script>
<script src="../includes/common/js/utility.js" type="text/javascript"></script>
<script src="../includes/skins/style.js" type="text/javascript"></script><script src="../includes/nxt/scripts/list.js" type="text/javascript"></script><script src="../includes/nxt/scripts/list.js.php" type="text/javascript"></script><script type="text/javascript">
$NXT_LIST_SETTINGS = {
  duplicate_buttons: true,
  duplicate_navigation: true,
  row_effects: true,
  show_as_buttons: true,
  record_counter: true
}
</script><style type="text/css">
  /* Dynamic List row settings */
  .KT_col_idPBH {
	width:100px;
	overflow:hidden;
}
  .KT_col_idHang {width:140px; overflow:hidden;}
  .KT_col_TGTraSP {width:140px; overflow:hidden;}
  .KT_col_TinhTrang {
	width:100px;
	overflow:hidden;
}
</style>
<script type="text/javascript" src="../includes/common/js/sigslot_core.js"></script>
<script type="text/javascript" src="../includes/wdg/classes/MXWidgets.js"></script>
<script type="text/javascript" src="../includes/wdg/classes/MXWidgets.js.php"></script>
<script type="text/javascript" src="../includes/wdg/classes/Calendar.js"></script>
<script type="text/javascript" src="../includes/wdg/classes/SmartDate.js"></script>
<script type="text/javascript" src="../includes/wdg/calendar/calendar_stripped.js"></script>
<script type="text/javascript" src="../includes/wdg/calendar/calendar-setup_stripped.js"></script>
<script src="../includes/resources/calendar.js"></script>



</head>

<body>

<?php include("admin_template/header.php"); ?>
<?php include("admin_template/admin_banner.php"); ?>  
<table id="main" width="990" border="1" align="center" cellpadding="0" cellspacing="0">
 <tr>
    <td width="200" align="left" valign="top" bgcolor="#66CC00" id="cottrai">
      <div align="left">
      <?php include("menu.php"); ?>  
      </div>       </td>
    <td id="cotphai" width="790" align="left" valign="top" bgcolor="#FFFFFF">
    
<div class="KT_tng" id="listphieubaohanh3">
  <h1> Danh sách phiếu bảo hành
    <?php
  $nav_listphieubaohanh3->Prepare();
  require("../includes/nav/NAV_Text_Statistics.inc.php");
?>
  </h1>
  <div class="KT_tnglist">
    <form action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>" method="post" id="form1">
      <div class="KT_options"> <a href="<?php echo $nav_listphieubaohanh3->getShowAllLink(); ?>">Hiện
            <?php 
  // Show IF Conditional region1
  if (@$_GET['show_all_nav_listphieubaohanh3'] == 1) {
?>
            <?php echo $_SESSION['default_max_rows_nav_listphieubaohanh3']; ?>
            <?php 
  // else Conditional region1
  } else { ?>
            tất cả
            <?php } 
  // endif Conditional region1
?>
           dữ liệu</a> &nbsp;
        &nbsp;
                            <?php 
  // Show IF Conditional region2
  if (@$_SESSION['has_filter_tfi_listphieubaohanh3'] == 1) {
?>
                            <a href="<?php echo $tfi_listphieubaohanh3->getResetFilterLink(); ?>">Đóng bộ lọc</a>
                            <?php 
  // else Conditional region2
  } else { ?>
                            <a href="<?php echo $tfi_listphieubaohanh3->getShowFilterLink(); ?>">Hiện bộ lọc</a>
                            <?php } 
  // endif Conditional region2
?>
      </div>
      <table cellpadding="2" cellspacing="0" class="KT_tngtable">
        <thead>
          <tr class="KT_row_order">
            <th> <input type="checkbox" name="KT_selAll" id="KT_selAll"/>
            </th>
            <th id="idPBH" class="KT_sorter KT_col_idPBH <?php echo $tso_listphieubaohanh3->getSortIcon('phieubaohanh.idPBH'); ?>"> <a href="<?php echo $tso_listphieubaohanh3->getSortLink('phieubaohanh.idPBH'); ?>">ID Phiếu</a> </th>
            <th id="idHang" class="KT_sorter KT_col_idHang <?php echo $tso_listphieubaohanh3->getSortIcon('hangsx.TenHang'); ?>"> <a href="<?php echo $tso_listphieubaohanh3->getSortLink('hangsx.TenHang'); ?>">Nhà cung ứng</a> </th>
            <th id="TGTraSP" class="KT_sorter KT_col_TGTraSP <?php echo $tso_listphieubaohanh3->getSortIcon('phieubaohanh.TGTraSP'); ?>"> <a href="<?php echo $tso_listphieubaohanh3->getSortLink('phieubaohanh.TGTraSP'); ?>">Thời gian trả</a> </th>
            <th id="TinhTrang" class="KT_sorter KT_col_TinhTrang <?php echo $tso_listphieubaohanh3->getSortIcon('phieubaohanh.TinhTrang'); ?>"> <a href="<?php echo $tso_listphieubaohanh3->getSortLink('phieubaohanh.TinhTrang'); ?>">Tình trạng</a> </th>
            <th>&nbsp;</th>
          </tr>
          <?php 
  // Show IF Conditional region3
  if (@$_SESSION['has_filter_tfi_listphieubaohanh3'] == 1) {
?>
          <tr class="KT_row_filter">
            <td>&nbsp;</td>
            <td><input type="text" name="tfi_listphieubaohanh3_idPBH" id="tfi_listphieubaohanh3_idPBH" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listphieubaohanh3_idPBH']); ?>" size="12" maxlength="100" /></td>
            <td><select name="tfi_listphieubaohanh3_idHang" id="tfi_listphieubaohanh3_idHang">
              <option value="" <?php if (!(strcmp("", @$_SESSION['tfi_listphieubaohanh3_idHang']))) {echo "SELECTED";} ?>><?php echo NXT_getResource("None"); ?></option>
              <?php
do {  
?>
              <option value="<?php echo $row_Recordset4['idHang']?>"<?php if (!(strcmp($row_Recordset4['idHang'], @$_SESSION['tfi_listphieubaohanh3_idHang']))) {echo "SELECTED";} ?>><?php echo $row_Recordset4['TenHang']?></option>
              <?php
} while ($row_Recordset4 = mysql_fetch_assoc($Recordset4));
  $rows = mysql_num_rows($Recordset4);
  if($rows > 0) {
      mysql_data_seek($Recordset4, 0);
	  $row_Recordset4 = mysql_fetch_assoc($Recordset4);
  }
?>
            </select>
            </td>
            <td><input name="tfi_listphieubaohanh3_TGTraSP" id="tfi_listphieubaohanh3_TGTraSP" value="<?php echo @$_SESSION['tfi_listphieubaohanh3_TGTraSP']; ?>" size="10" maxlength="22" wdg:mondayfirst="false" wdg:subtype="Calendar" wdg:mask="<?php echo $KT_screen_date_format; ?>" wdg:type="widget" wdg:singleclick="false" wdg:restricttomask="no" wdg:readonly="true" /></td>
            <td><input  <?php if (!(strcmp(KT_escapeAttribute(@$_SESSION['tfi_listphieubaohanh3_TinhTrang']),"1"))) {echo "checked";} ?> type="checkbox" name="tfi_listphieubaohanh3_TinhTrang" id="tfi_listphieubaohanh3_TinhTrang" value="1" /></td>
            <td><input type="submit" name="tfi_listphieubaohanh3" value="Lọc" /></td>
          </tr>
          <?php } 
  // endif Conditional region3
?>
        </thead>
        <tbody>
          <?php if ($totalRows_rsphieubaohanh1 == 0) { // Show if recordset empty ?>
          <tr>
            <td colspan="6"><?php echo NXT_getResource("Dữ liệu đang rỗng hoặc từ khóa lọc của bạn quá dài."); ?></td>
          </tr>
          <?php } // Show if recordset empty ?>
          <?php if ($totalRows_rsphieubaohanh1 > 0) { // Show if recordset not empty ?>
          <?php do { ?>
          <tr class="<?php echo @$cnt1++%2==0 ? "" : "KT_even"; ?>">
            <td><input type="checkbox" name="kt_pk_phieubaohanh" class="id_checkbox" value="<?php echo $row_rsphieubaohanh1['idPBH']; ?>" />
                <input type="hidden" name="idPBH" class="id_field" value="<?php echo $row_rsphieubaohanh1['idPBH']; ?>" />
            </td>
            <td><div class="KT_col_idPBH"><?php echo KT_FormatForList($row_rsphieubaohanh1['idPBH'], 20); ?></div></td>
            <td><div class="KT_col_idHang"><?php echo KT_FormatForList($row_rsphieubaohanh1['idHang'], 20); ?></div></td>
            <td><div class="KT_col_TGTraSP"><?php echo KT_formatDate($row_rsphieubaohanh1['TGTraSP']); ?></div></td>
            <td><div class="KT_col_TinhTrang"><?php echo KT_FormatForList($row_rsphieubaohanh1['TinhTrang'], 20); ?></div></td>
            <td><a class="KT_edit_link" href="FormPhieuBaoHanh.php?idPBH=<?php echo $row_rsphieubaohanh1['idPBH']; ?>&amp;KT_back=1">Sửa</a> <a class="KT_delete_link" href="#delete">Xóa</a> </td>
          </tr>
          <?php } while ($row_rsphieubaohanh1 = mysql_fetch_assoc($rsphieubaohanh1)); ?>
          <?php } // Show if recordset not empty ?>
        </tbody>
      </table>
      <div class="KT_bottomnav">
        <div>
          <?php
            $nav_listphieubaohanh3->Prepare();
            require("../includes/nav/NAV_Text_Navigation.inc.php");
          ?>
        </div>
      </div>
      <div class="KT_bottombuttons">
        <div class="KT_operations">  <a class="KT_delete_op_link" href="#" onclick="nxt_list_delete_link_form(this); return false;">Xóa nhiều</a> </div>
        <span>&nbsp;</span>
     
        <a class="KT_additem_op_link" href="FormPhieuBaoHanh.php?KT_back=1" onclick="return nxt_list_additem(this)">Thêm</a> </div>
    </form>
  </div>
  <br class="clearfixplain" />
</div>
<p>&nbsp;</p>

 </tr>
</table>
<?php include("admin_template/footer.php"); ?>  
</body>
</html>
<?php
mysql_free_result($Recordset3);

mysql_free_result($Recordset4);

mysql_free_result($rsphieubaohanh1);
?>
